/**
* 描述：系统消息
*/
<style lang="scss" scoped>
  @import '../index';
</style>
<template>
  <div style="width:100%; height:100%;">
    <div class="com-main-title">
      <span class="tit">系统消息</span>
      <div class="clear"></div>
    </div>
    <div style="padding:15px;">
      <table class="table-list-normal">
        <div class="noData" v-show="list && list.length == 0">暂无数据 :-)</div>
        <tr>
          <td>通知内容</td>
          <td>创建时间</td>
          <td>确认时间</td>
        </tr>
        <tr v-for="item in list">
          <td>{{item.notice}}</td>
          <td>{{item.createdAt | formatDate2}}</td>
          <td>{{item.ackTime | formatDate2}}</td>
          <td><div class="btns" @click="goToJobDetail(item.id)" style="width:100px;">已读</div></td>
        </tr>
      </table>
      <div style="float: right;margin-top: 10px;">
        <template>
          <Page :total="totalElement" show-elevator :current="searchData.pageNo" :page-size="searchData.pageSize" @on-change="_getList"></Page>
        </template>
      </div>
    </div>
  </div>
</template>
<script>
  import { mapActions } from 'vuex';
  import list from '@/js/mixins/list';
  import { systemInfoList, systemInfoCount, noticeAck } from '@/service/web/user/systemInfoService';
  export default {
    mixins: [list],
    data () {
      return {
        loading: false,
        list: [],
        pageCount: 0,
        searchData: {
          pageNo: 1,
          pageSize: 5
        }
      };
    },
    mounted () {
      this._getList();
    },
    methods: {
      ...mapActions([
        'getSysInfoCount'
      ]),
      // 查询列表
      async _getList () {
        this.loading = true;
        let result = await systemInfoList(this.searchData);
        let temp = await systemInfoCount();
        if (!result.data.length) result.data = null;
        this.list = result.data || [];
        this.pageCount = temp.data || 0;
        this.loading = false;
      },
      // 跳转到职务详情
      async goToJobDetail (id) {
        await noticeAck({id: id});
        this.$Notice.success({title: '操作成功'});
        this.getSysInfoCount();
      }
    }
  };
</script>
